/**
 * 
 */
package connectors;

import java.util.ArrayList;
import java.util.List;

/**
 * @author Lucas 'Mezmor' Pfister, Vishal Patel
 * 
 * Format of data strings are as follows:
 * unit moves from a1 to b2 and from a2 to b3
 * "a1,b2"
 * "a2,b3"
 * is encoded as
 * "a1,b2;a2,b3"
 *
 */
public class Data {
	
	public Data() {
		
	}
	
	/**
	 * Convert List -> String
	 * @param data
	 * @return
	 */
	public String getString(List<String> data) {
		String returnString = new String(data.get(0));
		
		if(data.size() == 1)
			return returnString;
		
		for(int i = 1; i < data.size(); i++){
			returnString = returnString.concat(";");
			returnString = returnString.concat(data.get(i));
		}
		
		return returnString;
	}
	
	/**
	 * Convert String -> List
	 * @param data
	 * @return
	 */
	public List<String> getArray(String data){
		String[] splitString = data.split(";");
		List<String> returnList = new ArrayList<String>();
		
		for(String str : splitString)
			returnList.add(str);
		
		return returnList;
	}
}